using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Xml;
using log4net;
using log4net.Config;

namespace SharePointSearchBench.Library.Logging
{
    /// <summary>
    /// Used for writing debug messages to a log.  Provides method start/begin
    /// information and can be disposed.
    /// </summary>
    public class DisposableDebugLogWriter : IDisposableLogWriter
    {
        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        public DisposableDebugLogWriter()
        {
            DebugLogWriter.WriteMessageInternal("");           
        }

        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        public DisposableDebugLogWriter(string message)
        {
            DebugLogWriter.WriteMessageInternal(string.Format("BEGIN: {0}",message));
        }

        /// <summary>
        /// Writes a debug message to a log.
        /// </summary>
        /// <param name="message"></param>
        public void WriteMessage(string message)
        {
            DebugLogWriter.WriteMessageInternal(message);
        }

        /// <summary>
        /// Disposes the object.
        /// </summary>
        public void Dispose()
        {
            DebugLogWriter.WriteMessageInternal("END");
        }

    }
}
